
<%@page import="beans.FAQbean"%>
<%@page import="java.util.List"%>
<%@page import="dao.FAQ"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <script language="javascript">
            function delete1()
            {
                return confirm('Do you want delete this record');
            }
        </script>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>FAQ</title>
        <style>                        
            table, th, td {
                border: 1px solid #619702;
                border-collapse: collapse;
                width:99.3% ;
            }
            th, td {
                padding: 5px;
                width: 100px;
            }
            th {
                text-align: center;
            }
        </style>
    </head>
    <body>
        <%
            if (request.getAttribute("msg") != null) {
        %>
        <font color="green" > <%= request.getAttribute("msg")%> </font>
        <%
            }
        if (request.getAttribute("error") != null) {
        %>
        <font color="red" > <%= request.getAttribute("error")%> </font>
        <%
            }
        %>
        <br>
        <a href="index.jsp?page=create_FAQ">Create new FAQ</a>  
        <br>
        <br> 
        <% FAQ faqB = new FAQ();
            List<FAQbean> listF = faqB.showFAQ();
        %>

        <table>                
            <tr>
                <th style="width: 30px">Id</th>
                <th>Question</th>		
                <th>Answer</th>                
                <th>Edit</th>
                <th>Delete</th>
            </tr> 
            <%  for (FAQbean FBean : listF) {
            %>
            <tr>
                <th style="width: 30px"><%= FBean.getFaq_id()%></th>
                <th><%= FBean.getFaq_question()%></th>		
                <th><%= FBean.getFaq_answer()%></th>               
                <th>
            <form action="editFAQ" method ="get">
                <input type="hidden" name="action" value="update">
                <input type="hidden" name="faq_id" value="<%= FBean.getFaq_id()%>">              
                <input type="hidden" name="question" value="<%= FBean.getFaq_question()%>">
                <input type="hidden" name="answer" value="<%= FBean.getFaq_answer()%>">                       
                <input type="submit" value="Update">
            </form>
        </th>
        <th>
        <form action="editFAQ" method ="get">
            <input type="hidden" name="action" value="delete">
            <input type="hidden" name="faq_id" value="<%= FBean.getFaq_id()%>">
            <input type="submit" value="Delete" onclick='return delete1()'>
        </form>
    </th>
</tr>   
<%
    }
%>
</table>
</body>
</html>
